<!DOCTYPE html>
<html>
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.0.0-rc.3'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv='x-dns-prefetch-control' content='on' />

  <!-- 页面元数据 -->
  
  <title>Java面向对象 (继承、多态) - DataScience</title>
  
    <meta name="keywords" content="Java">
  

  
    <meta name="description" content="Java面向对象 继承 多态">
  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/heson525/fontawesome-pro@5.13.1/css/all.min.css">

  
  

  

  
    <link rel="shortcut icon" type='image/x-icon' href="/favicon.ico">
  

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.css">
  

  

  <!-- import link -->
  

  
    
      
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.2.0/styles/a11y-dark.css">

    
  
  
    
<link rel="stylesheet" href="/css/style.css">

  
  
  
  <!-- 脚本懒加载函数 -->
  <script>
  function loadScript(src, cb) {
    var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
    var script = document.createElement('script');
    script.setAttribute('type','text/javascript');
    if (cb) script.onload = cb;
    script.setAttribute('src', src);
    HEAD.appendChild(script);
  }
  //https://github.com/filamentgroup/loadCSS
  !function(c){"use strict";var e=function(e,t,n,r){var o,i=c.document,a=i.createElement("link");if(t)o=t;else{var d=(i.body||i.getElementsByTagName("head")[0]).childNodes;o=d[d.length-1]}var f=i.styleSheets;if(r)for(var l in r)r.hasOwnProperty(l)&&a.setAttribute(l,r[l]);a.rel="stylesheet",a.href=e,a.media="only x",function e(t){if(i.body)return t();setTimeout(function(){e(t)})}(function(){o.parentNode.insertBefore(a,t?o:o.nextSibling)});var s=function(e){for(var t=a.href,n=f.length;n--;)if(f[n].href===t)return e();setTimeout(function(){s(e)})};function u(){a.addEventListener&&a.removeEventListener("load",u),a.media=n||"all"}return a.addEventListener&&a.addEventListener("load",u),(a.onloadcssdefined=s)(u),a};"undefined"!=typeof exports?exports.loadCSS=e:c.loadCSS=e}("undefined"!=typeof global?global:this);
  </script>
  <script id="loadcss"></script>
</head>

<body>
  <header class="l_header auto shadow blur " style='opacity: 0' >
  <div class='container'>
  <div class='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a class="s-comment fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/'>
          
            <img no-lazy class='logo' src='https://7.dusays.com/2020/12/02/16aab31b3dcfe.png'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
                <li>
                  <a class="menuitem flat-box">
                    <i class='fas fa-compact-disc fa-fw music'></i>音乐
                  </a>
                  <ul class="list-v">
                    <li>
                      <div class="aplayer-container">
                        

  
    <meting-js
      theme='#1BCDFC'
      volume='0.3'
      loop='all'
      order='random'
      fixed='false'
      list-max-height='320px'
      server='netease'
      type='playlist'
      id='5229739363'
      list-folded='true'>
    </meting-js>
  


                      </div>
                    </li>
                  </ul>
                <li>
              
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fal fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="想找些什么~" />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div class="l_body">
    <div class="l_cover">
  
    
    
        <div class='cover-wrapper post featured' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://7.dusays.com/2020/09/10/bcac99047bac5.png"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">数据科学</p>
    
    
      <p class="subtitle">Welcome To A2Data</p>
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/categories/"
              
              
              id="categories">
              <i class='fal fa-folder-open fa-fw fa-fw'></i><p>内容大纲</p>
            </a>
          
            <a href="/archives/"
              
              
              id="archives">
              <i class='fal fa-archive fa-fw fa-fw'></i><p>文章归档</p>
            </a>
          
            <a href="/tags/"
              
              
              id="tags">
              <i class='fal fa-fire fa-fw fa-fw fa-fw'></i><p>热门标签</p>
            </a>
          
            <a href="/contact/"
              
              
              id="contact">
              <i class='fal fa-comments fa-fw fa-fw'></i><p>畅所欲言</p>
            </a>
          
            <a href="/Creator-said/"
              
              
              id="Creator-said">
              <i class='fal fa-microphone-alt fa-fw fa-fw'></i><p>随便说说</p>
            </a>
          
            <a href="/friends/"
              
              
              id="friends">
              <i class='fal fa-link fa-fw fa-fw'></i><p>我的朋友</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div class="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>
  
    <div class='safearea'>
      <div class='body-wrapper' id="pjax-container">
        
          <!--此文件用来存放一些不方便取值的变量--> 
<!--思路大概是将值藏到重加载的区域内--> 
 
 
 
<div id="pjax-data" style="display: none"> 
  <div id="pjax-ispage">true</div> 
  <div id="pjax-pageTitle">Java面向对象 (继承、多态)</div> 
  <div id="pjax-enable-cover">true</div> 
  <div id="pjax-comment-path"></div> 
  <div id="pjax-comment-placeholder"></div> 
</div> 
 
 
<script> 
  // 处理封面 此时 jquery 还没加载 
  if ("none" == "none") { // 移除封面 
    document.getElementsByClassName('cover-wrapper')[0].style.display = "none"; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.add("show"); 
  } else { 
    if ("none" == "half") { // 半屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'half'); 
      document.getElementsByClassName('scroll-down')[0].style.display = "none"; 
    } else if ("none" == "full") { // 全屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'full'); 
      document.getElementsByClassName('scroll-down')[0].style.display = ""; 
    } 
    document.getElementsByClassName('cover-wrapper')[0].style.display = ""; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.remove("show"); 
  } 
</script> 
 

        
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
      <a title='Java面向对象 (继承、多态)' href='/posts/43249.html'>
        <img class='thumbnail' src='https://gitee.com/DataITems/cdn/raw/master/20200508000334.png'>
      </a>
    
    
      <h1 class="title">
        Java面向对象 (继承、多态)
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="https://gitee.com/DataITems/cdn/raw/master/avatar.png">
    <p>JackFeng</p>
  </a>
</div>

          
        
          
            <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：May 7, 2020</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/categories/Java/">Java</a>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>4.2k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>17 min</p>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="Java面向对象 (继承、多态)" data-path="/posts/43249.html">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
          
            
<div class="new-meta-item comments-count">
  
  <a href="/posts/43249.html#comments">
    <i class="fas fa-comment-dots fa-fw"></i>
    <span class="valine-comment-count" data-xid="/posts/43249.html">0</span>
    <span class="leancloud-comments-count">&nbsp;</span>
  </a>
</div>


          
        
      </div>
    
  </div>


  
  
  <p>Java面向对象 继承 多态</p>
<a id="more"></a>

<h1 id="面向对象-继承、多态"><a href="#面向对象-继承、多态" class="headerlink" title="面向对象 (继承、多态)"></a>面向对象 (继承、多态)</h1><h2 id="1、static静态"><a href="#1、static静态" class="headerlink" title="1、static静态"></a>1、static静态</h2><blockquote>
<p>static（静态） <em>关键字</em></p>
<p>用于修饰成员变量和成员方法</p>
<p><strong>特点：</strong></p>
<ul>
<li>被所有的对象所共享</li>
<li>可以使用类名调用</li>
<li>静态加载优先于对象</li>
<li>随着类的加载而加载</li>
</ul>
<p><strong>注意事项：</strong></p>
<ul>
<li>静态方法只能访问静态成员</li>
<li>非静态方法既可以访问静态也可以访问非静态</li>
<li>非静态方法中不可以定义静态变量</li>
<li>静态方法中不可以定义this，super关键字</li>
</ul>
<p><strong>优缺点：</strong></p>
<ul>
<li>优点<ul>
<li>对对象的共享数据提供单独的存储空间，节省空间</li>
<li>直接被类名调用，不用在堆内存创建对象</li>
</ul>
</li>
<li>缺点<ul>
<li>访问出现局限性（只能访问静态）</li>
</ul>
</li>
</ul>
</blockquote>
<pre><code class="java">package one;

/**
 * Created by JackFeng on 2020/3/8.
 */

public class StaticDemo &#123;
    public static void main(String[] args) &#123;

        /*
        * Math 主要的数学运算方法
        * */

//        static double abs ( double a) : 返回绝对值
        System.out.println(Math.abs(15));
        System.out.println(Math.abs(-10));
        System.out.println(&quot;----------&quot;);

        // ceil  天花板 向上取整
        System.out.println(Math.ceil(1.2));
        System.out.println(Math.ceil(1.6));
        System.out.println(&quot;----------&quot;);

        // floor 向下取整
        System.out.println(Math.floor(1.2));
        System.out.println(Math.floor(1.8));
        System.out.println(&quot;==========&quot;);


        // round 四舍五入
        System.out.println(Math.round(1.2));
        System.out.println(Math.round(1.6));
        System.out.println(&quot;---------&quot;);


        // max  min
        System.out.println(Math.max(3,8));

        // pow 次幂  第一个参数的第二个参数次幂

        System.out.println(&quot;2 的3 次方&quot;);
        System.out.println(Math.pow(2,3));

        // random 随机数  大于0 &lt;1
        System.out.println(Math.random());


    &#125;
&#125;

</code></pre>
<h2 id="2、代码块"><a href="#2、代码块" class="headerlink" title="2、代码块"></a>2、代码块</h2><blockquote>
<p>写一个数据操作的工具类，取最大值，已经取数组中指定索引的值</p>
</blockquote>
<p><strong>MyArray</strong> 工具类</p>
<pre><code class="java">package com.a2data;

/**
 * Created by JackFeng on 2020/3/13.
 */
public class MyArrays &#123;
    // 数组操作 有关的工具类 ，不需要创建对象，所以 可以私有他的构造方法

    private MyArrays()&#123;&#125;


    // 取最大值

    public static  int getMax(int[] arr)&#123;

        // 定义参照物
        int max = arr[0];
        for (int i = 1; i &lt;arr.length ; i++) &#123;

            if (max&lt;arr[i])&#123;
                // 替换参照物
                max = arr[i];
            &#125;
        &#125;
        return max;
    &#125;

    // 获取指定数组中指定元素的索引位置

    public static int getIndex(int[] arr,int a)&#123;

        for (int i = 0; i &lt;arr.length ; i++) &#123;
            if (arr[i]== a)
                return i;
        &#125;
        return -1;
    &#125;


&#125;


</code></pre>
<p><strong>MyArrayDemo</strong>  工具类使用</p>
<pre><code class="java">package com.a2data;

/**
 * Created by JackFeng on 2020/3/13.
 */
public class MyArrayDemo &#123;
    public static void main(String[] args) &#123;
        int[] arr = &#123;1, 2, 3, 4, 5, 21&#125;;

        int max = MyArrays.getMax(arr);

        System.out.println(max);

        int index = MyArrays.getIndex(arr, 3);
        int index1 = MyArrays.getIndex(arr, 6);
        System.out.println(index);
        System.out.println(index1);
    &#125;
&#125;

</code></pre>
<blockquote>
<p>局部代码块：</p>
<p>​    存在于方法中，控制变量的生命周期（作用域）</p>
<p>构造代码块：</p>
<p>​    去构造方法中的共性，每次创建对象都会执行，并且在构造方法执行之前执行。</p>
<p>静态代码块：</p>
<p>​    随着类的加载而加载，只加载一次，加载类时需要加载的驱动</p>
</blockquote>
<h2 id="3、继承"><a href="#3、继承" class="headerlink" title="3、继承"></a>3、继承</h2><blockquote>
<p>继承：<strong>Extends</strong></p>
<p>​    多个类有共同的成员变量和成员方法，抽取到另外一个类中（父类）</p>
<p><em>只能继承一个父类。</em>  — 只有一个亲爹</p>
<p><em>只能继承父类非私有成员</em></p>
<p><em>支持多层继承</em>   — 还可以有一个亲爷爷</p>
</blockquote>
<p><strong>super</strong>  与<em>this</em>相似，获取父类的成员和方法。 就近原则！</p>
<blockquote>
<p>方法重写：</p>
<p>​    在子父类当中,子类的方法和父类的方法完全一样，子类重写了父类的方法(覆盖)。并且<em>super</em> 调用父类的方法即可。</p>
</blockquote>
<blockquote>
<p>注意事项：</p>
<ul>
<li>不能重写父类私有的方法</li>
<li>必须大于等于父类方法的权限</li>
</ul>
<p>注解：@</p>
<ul>
<li>@Override</li>
</ul>
<p>继承中构造方法的执行顺序：</p>
<p><strong>子父类继承关系</strong></p>
<ul>
<li>创建了子类的对象，就会调用子类的构造方法</li>
<li>子类构造方法第一行没有调用父类构造方法，默认调用父类无参构造</li>
<li>肯定先执行父类方法，因为要先给父类的成员变量进行初始化，子类可能会用到。</li>
</ul>
<p><em>super() 在子类构造方法的第一行中调用父类的构造方法</em></p>
<p><strong>继承优缺点</strong></p>
<p>优点：</p>
<ul>
<li>提高代码的复用性，可维护性</li>
</ul>
<p>缺点：</p>
<ul>
<li>耦合性的影响。</li>
</ul>
<p>开发原则： <strong>高内聚低耦合</strong></p>
<ul>
<li>内聚：自己完成某件事的能力</li>
<li>耦合：类与类的关系</li>
</ul>
</blockquote>
<pre><code class="java">package com.a2data;

/**
 * Created by JackFeng on 2020/3/13.
 */
public class ExtendsDemo &#123;
    public static void main(String[] args) &#123;
        Zi zi = new Zi();
        zi.function();

    &#125;

  static class Die &#123;
      int num = 11;

      Die()&#123;
          System.out.println(&quot;我是父类无参构造&quot;);
      &#125;
      public Die(int num)&#123;
          System.out.println(&quot;我是父类有参构造&quot;);
      &#125;

      public void method()&#123;
          System.out.println(&quot;我是父类的方法&quot;);
      &#125;

  &#125;

  static class Zi extends Die&#123;

      int num = 2020;

      Zi()&#123;
          this(1);  // 第一行不调用子类，或者其他方法，默认调用父类

          System.out.println(&quot;我是子类无参构造&quot;);
      &#125;
      Zi(int num)&#123;
          System.out.println(&quot;我是子类有参构造&quot;);
      &#125;


      public void  method()&#123;
          System.out.println(&quot;我是子类的方法&quot;);
      &#125;

      void function()&#123;
//          this.method();

          this.num = 20;
      &#125;

  &#125;

&#125;

</code></pre>
<h4 id="this和super的区别"><a href="#this和super的区别" class="headerlink" title="this和super的区别"></a>this和super的区别</h4><blockquote>
<p>this和super的区别：</p>
<ul>
<li>this： 当前对象的引用<ul>
<li>调用子类的成员变量</li>
<li>调用子类的成员方法</li>
<li>在子类的构造方法第一行调用子类其他构造方法</li>
</ul>
</li>
<li>super ： 子类对象的父类引用<ul>
<li>调用父类的成员变量</li>
<li>调用父类的成员方法</li>
<li>在子类的构造方法第一行调用父类的构造方法</li>
</ul>
</li>
</ul>
</blockquote>
<h2 id="4、匿名对象-amp-final"><a href="#4、匿名对象-amp-final" class="headerlink" title="4、匿名对象&amp;final"></a>4、匿名对象&amp;final</h2><blockquote>
<p>匿名对象：没有名字的对象</p>
<p>场景：</p>
<p>​    当方法只是使用一次的时候，可以使用匿名对象</p>
<p>​    可以当做参数传递，但无法进行操作</p>
<p>注意：</p>
<p>​    匿名对象可以调用成员对象，并赋值，但是并没有意义，因为只调用一次</p>
</blockquote>
<pre><code class="java">package com.a2data;


/**
 * Created by JackFeng on 2020/3/13.
 */
public class AnonyDemo &#123;
    public static void main(String[] args) &#123;

//        Student s = new Student();
//        s.study();

        new Student(); // 匿名对象，没有变量名引用的对象

    &#125;
&#125;

class Student&#123;
    String name;
    int age;

    public void study()&#123;
        System.out.println(&quot;加油提升自己&quot;);
    &#125;
&#125;
</code></pre>
<h3 id="Final"><a href="#Final" class="headerlink" title="Final"></a>Final</h3><blockquote>
<p>修饰符： 可以用于修饰类，成员方法和成员变量</p>
</blockquote>
<blockquote>
<p>final所修饰的类，不可被继承，不能有子类</p>
<p>final所修饰的方法，不能被重写。</p>
<p>final所修饰的变量，是不可修改的，是常量</p>
<p><strong>常量</strong>：</p>
<ul>
<li>字面值常量： 1,2,3</li>
<li>自定义常量：被final所修饰的成员变量，一旦初始化则不可改变</li>
</ul>
<p><strong>注意：</strong></p>
<ul>
<li>自定义常量必须初始化，可以选择显示初始化或者构造初始化</li>
</ul>
</blockquote>
<h2 id="5、抽象类"><a href="#5、抽象类" class="headerlink" title="5、抽象类"></a>5、抽象类</h2><blockquote>
<p><strong>abstract:</strong> 关键字，用于修饰方法和类</p>
<p><em>抽象方法</em>：</p>
<p>​    不同类的方法是相似的，但是具体内容又不太一样，所以我们智能抽取它的申明，没有具体的方法体，没有具体方法体的方法就是<em>抽象方法</em></p>
<p><em>抽象类：</em></p>
<p>​    有抽象方法的类必须是抽象类</p>
<p>​    <strong>特点：</strong></p>
<ul>
<li>抽象方法只能在抽象类里边</li>
<li>抽象类和抽象方法必须被abstract修饰</li>
<li>抽象类不能创建对象（不能实例化）</li>
<li>抽象类中可以有非抽象的方法</li>
<li>抽象类和类的关系也是继承</li>
</ul>
<p><em>抽象类的成员特点</em></p>
<ul>
<li>成员变量<ul>
<li>可以有成员变量</li>
<li>可以有常量</li>
</ul>
</li>
<li>成员方法<ul>
<li>可以有抽象方法</li>
<li>可以有非抽象方法</li>
</ul>
</li>
<li>构造方法<ul>
<li>可以有构造方法的，需要对抽象类的成员变量进行初始化</li>
</ul>
</li>
</ul>
<p><em>注意：</em></p>
<p>​    一个类继承了抽象类需要重写他所有的抽象方法,否则这个类就得是抽象类</p>
</blockquote>
<pre><code class="java">package com.a2data;

import sun.plugin2.message.JavaReplyMessage;

/**
 * Created by JackFeng on 2020/3/15.
 */


/*
*
* 普通教练，高级教练
*
*
* 共性：
*   属性  姓名 年龄 性别
*   行为  教学
*
* */

public class AbastractTest &#123;
    public static void main(String[] args) &#123;

        BasicTeacher bt = new BasicTeacher();
        bt.name = &quot;小白教练&quot;;
        bt.teach();


        JobTeacher jt = new JobTeacher();
        jt.name = &quot;小灰教练&quot;;
        jt.teach();


    &#125;
&#125;


abstract class  Teacher&#123;
    String name; // 姓名
    int age; // 年龄
    String gender;

    public abstract void teach();

&#125;

class BasicTeacher extends Teacher&#123;

    @Override
    public void teach() &#123;
        System.out.println(name + &quot;讲基础内容&quot;);
    &#125;
&#125;


class JobTeacher extends Teacher&#123;

    @Override
    public void teach() &#123;
        System.out.println(name+ &quot;讲高级实战内容&quot;);
    &#125;
&#125;



</code></pre>
<h2 id="6、接口"><a href="#6、接口" class="headerlink" title="6、接口"></a>6、接口</h2><blockquote>
<p><strong>interface</strong>: 接口是一个比抽象类还抽象的类，接口里所有的方法全是抽象方法,接口和类的关系是实现，<em>implements</em></p>
<p><strong>格式：</strong></p>
<ul>
<li><p>interface  接口名 {</p>
<p>​    </p>
<p>}</p>
</li>
</ul>
<p><strong>特点：</strong></p>
<ul>
<li>只能有抽象方法</li>
<li>只能有常量 </li>
<li>只能用 publie&amp;abstract 方法</li>
<li>默认使用public static final 来修饰成员变量</li>
<li><em>建议</em> 手动输入默认修饰符（public&amp;abstract），虽然不输入也会是默认的。</li>
</ul>
<p><strong>注意：</strong></p>
<ul>
<li>接口不能创建对象（不能实例化）</li>
<li>类与接口的关系是实现关系，一个类实现一个接口必须实现它的所有方法</li>
</ul>
<p>类与类：继承关系，单一继承，多层继承</p>
<p>类与接口：实现关系，多实现</p>
<p>接口与接口关系： 继承关系，多层继承</p>
</blockquote>
<blockquote>
<p>接口优点：</p>
<ul>
<li>1、类与接口的关系，实现关系，而且是多实现，一个类可以实现多个接口，类与类之间是继承关系，java中的继承是单一继承，一个类只能有一个父类，打破了继承的局限性</li>
<li>2、对外提供规则（统一要求，例如Use接口,充电器接口）</li>
<li>3、降低程序的耦合性<ul>
<li>定义规则，模块化开发</li>
<li>高内聚低耦合，提高开发效率</li>
</ul>
</li>
</ul>
</blockquote>
<blockquote>
<p>接口和抽象类的区别：</p>
<ul>
<li>共性： 抽取出抽象的概念</li>
<li>区别1：与类的关系<ul>
<li>类与接口是实现关系，多实现</li>
<li>类与抽象类是继承关系，Java中的继承是单一继承，一个类只能有一个父类，java中的继承是多层继承</li>
</ul>
</li>
<li>区别2：成员<ul>
<li>成员变量：<ul>
<li>抽象类可以有成员变量，也可以有常量</li>
<li>接口只能有常量</li>
</ul>
</li>
<li>成员方法：<ul>
<li>抽象类可以有抽象方法，也有非抽象方法</li>
<li>接口只能有抽象方法，默认修饰符 <em>public abstract</em></li>
</ul>
</li>
<li>构造方法：<ul>
<li>抽象类有构造方法的</li>
<li>接口没有构造方法</li>
</ul>
</li>
</ul>
</li>
</ul>
</blockquote>
<p><strong>接口开发的思路</strong></p>
<blockquote>
<p>分析：</p>
<p>​    由下至上    不断向上抽取</p>
<p>实现：</p>
<p>​    由上至下    先实现共性</p>
<p>应用：</p>
<p>​    使用具体的子类</p>
</blockquote>
<pre><code class="java">package com.a2data;

/**
 * Created by JackFeng on 2020/3/15.
 */


/*
*
* 篮球运动员和教练
* 乒乓球运动员和教练
* 篮球运动员和教练要出国访问，需要学习英语
*
*
*
* */


public class InterfaceTest &#123;
    public static void main(String[] args) &#123;
        //篮球运动员对象
        BasketBallPlayer bp = new BasketBallPlayer();
        bp.name = &quot;姚明&quot;;
        bp.age = 35;
        bp.gender = &quot;男&quot;;
        bp.sleep();
        bp.study();
        bp.speak();
        System.out.println(&quot;------------&quot;);
        //乒乓球教练对象

        PingpangCoache pp = new PingpangCoache();
        pp.name = &quot;刘教练&quot;;
        pp.age = 40;
        pp.gender = &quot;男&quot;;
        pp.sleep();
        pp.teach();
//        pp.speak()

    &#125;


&#125;


class  Person&#123;
    String name;
    int age;
    String gender;

    public Person() &#123;
    &#125;

    public Person(String name, int age, String gender) &#123;
        // 成员变量初始化
        this.name = name;
        this.age = age;
        this.gender = gender;
    &#125;


    public void eat()&#123;
        System.out.println(&quot;吃饭&quot;);
    &#125;


    public void sleep()&#123;
        System.out.println(&quot;睡觉&quot;);
    &#125;



&#125;

interface SpeakEnglish &#123;

    public abstract void speak();
&#125;


// 运动员
abstract class Player extends Person&#123;
    //学习
    public abstract void study();

&#125;

// 教练

abstract class Coach extends Person&#123;
    // 教
    public abstract void teach();

&#125;


//篮球运动员

class BasketBallPlayer extends Player implements SpeakEnglish&#123;

    @Override
    public void study() &#123;
        System.out.println(&quot;学扣篮&quot;);
    &#125;

    @Override
    public void speak() &#123;
        System.out.println(&quot;说英语&quot;);
    &#125;
&#125;


//乒乓球运动员

class  PingpangPlayer extends Player&#123;

    @Override
    public void study() &#123;
        System.out.println(&quot;学颠球&quot;);
    &#125;
&#125;


//篮球教练

class BasketBallCoach extends Coach implements SpeakEnglish&#123;

    @Override
    public void teach() &#123;
        System.out.println(&quot;教扣篮&quot;);
    &#125;

    @Override
    public void speak() &#123;
        System.out.println(&quot;说英语&quot;);
    &#125;
&#125;


//乒乓球教练
class PingpangCoache extends  Coach&#123;

    @Override
    public void teach() &#123;
        System.out.println(&quot;教颠球&quot;);
    &#125;
&#125;


</code></pre>
<h2 id="7、多态"><a href="#7、多态" class="headerlink" title="7、多态"></a>7、多态</h2><h3 id="前提"><a href="#前提" class="headerlink" title="前提"></a>前提</h3><blockquote>
<p><strong>多态的前提：</strong></p>
<ul>
<li>子父类继承关系</li>
<li>方法的重写</li>
<li>父类引用指向子类对象</li>
</ul>
<p>动态绑定：运行期间调用的方法，是根据具体的类型，具体的方法</p>
<p><strong>优缺点：</strong></p>
<ul>
<li>优点： 可以提高可维护性(多态前提所保证的)，提高代码的可扩展性</li>
<li>缺点： 无法直接访问子类特有的成员</li>
</ul>
</blockquote>
<pre><code class="java">package com.a2data;

/**
 * Created by JackFeng on 2020/3/15.
 */
public class PoymorphicDemo &#123;
    public static void main(String[] args) &#123;
//        Cat cat = new Cat();
//        cat.eat();

        // 父类引用  Animal a
        // 指向  =
        // 子类对象  new Cat()
        // 动态绑定
        Animal a = new Cat();
        a.eat();


    &#125;


&#125;

class Animal &#123;
    public void eat()&#123;
        System.out.println(&quot;c吃东西&quot;);
    &#125;
&#125;

class Cat extends Animal&#123;
    public void eat()&#123;
        System.out.println(&quot;猫吃鱼&quot;);
    &#125;
&#125;



</code></pre>
<h3 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h3><blockquote>
<p>多态的成员特点：</p>
<ul>
<li>成员变量<ul>
<li>编译时看的是左边，运行时看的是左边</li>
</ul>
</li>
<li>成员方法<ul>
<li>编译时看的是左边，运行时看的是右边</li>
</ul>
</li>
<li>静态方法<ul>
<li>编译时看的是左边，运行时看的是左边</li>
</ul>
</li>
</ul>
<p>编译时看的都是左边，运行时成员方法看的是右边，其他（成员变量和静态方法）看的都是左边</p>
</blockquote>
<pre><code class="java">package com.java;

import java.util.Date;

/**
 * Created by JackFeng on 2020/3/15.
 */
public class PoymorphicDemo &#123;
    public static void main(String[] args) &#123;

        // 成员变量
        // 在继承中没有被重写的概念，没有动态绑定的概念
        // 执行的是父类的

        Dad d = new Kid();
        System.out.println(d.num);


        // 成员方法
        // 运行看右边
        System.out.println(&quot;----------&quot;);
        d.method();

        // 静态方法
        d.function(); // 使用变量去调用静态方法，相当于用变量类型的类名去调用  所以输出父类的静态方法


    &#125;
&#125;


class  Dad&#123;
    int num = 1;


    public void method()&#123;
        System.out.println(&quot;我是父类的方法&quot;);
    &#125;

    public static void function()&#123;
        System.out.println(&quot;我是父类的静态方法&quot;);
    &#125;

&#125;

class Kid extends Dad&#123;
    int num = 21;

    public void method()&#123;

        System.out.println(&quot;我是子类的方法&quot;);
    &#125;

    public static void function()&#123;
        System.out.println(&quot;我是子类的静态方法&quot;);
    &#125;

&#125;

</code></pre>
<h3 id="多态转型"><a href="#多态转型" class="headerlink" title="多态转型"></a>多态转型</h3><blockquote>
<p>多态中的向上转型和向下转型：</p>
<ul>
<li>引用类型之间的转换<ul>
<li>向上转型<ul>
<li>由小到大（子类型转换成父类型)</li>
</ul>
</li>
<li>向下转型<ul>
<li>由大到小</li>
</ul>
</li>
</ul>
</li>
<li>基本数据类型的转换<ul>
<li>自动类型转换<ul>
<li>由小到大</li>
<li>byte short char – int — long — float – double</li>
</ul>
</li>
<li>强制类型转换<ul>
<li>由大到小</li>
</ul>
</li>
</ul>
</li>
</ul>
</blockquote>
<pre><code class="java">package com.java;

/**
 * Created by JackFeng on 2020/3/15.
 */
public class polymorphicDemo &#123;
    public static void main(String[] args) &#123;

        Animal a = new Dog(); // 向上转型
        a.eat();


        Dog d = (Dog) a; // 向下转型  本身是什么类型 转换成什么类型
        d.swim();

    &#125;
&#125;


class Animal&#123;
    public void eat()&#123;
        System.out.println(&quot;吃东西&quot;);
    &#125;

&#125;


class Dog extends  Animal&#123;

    public void eat()&#123;
        System.out.println(&quot;啃骨头&quot;);
    &#125;

    public void swim()&#123;
        System.out.println(&quot;狗刨&quot;);
    &#125;

&#125;

</code></pre>
<h2 id="8、权限修饰符"><a href="#8、权限修饰符" class="headerlink" title="8、权限修饰符"></a>8、权限修饰符</h2><h3 id="包"><a href="#包" class="headerlink" title="包"></a>包</h3><blockquote>
<p>特点：（<em>package</em>）</p>
<ul>
<li>可以由多层</li>
<li>不同包下的文件名可以重复</li>
<li>包的声明必须在第一行代码</li>
</ul>
</blockquote>
<h3 id="包使用场景"><a href="#包使用场景" class="headerlink" title="包使用场景"></a>包使用场景</h3><p><strong>类的全名：</strong> 包名.类名</p>
<blockquote>
<p>同包：</p>
<p>​    相同包下的类可以直接访问，不需要做其他的操作</p>
<p>异包:</p>
<p>​    1、使用类的全名</p>
<p>​    2、使用关键字import将类导入</p>
<p>注意：</p>
<p>***** 代表的是通配符，代表导入了这个包下所有的类,并没有导入子包下的类</p>
</blockquote>
<p><strong>权限修饰符</strong></p>
<blockquote>
<p>pubilc —- 访问都是对外的</p>
<ul>
<li>当前类，相同包下不同的类，不同包下的类</li>
</ul>
<p>default </p>
<ul>
<li>当前类，相同包下不同的类</li>
<li>当前包下使用(与protected)区别</li>
</ul>
<p>private</p>
<ul>
<li>仅限当前类</li>
</ul>
<p>protected — 数据保护</p>
<ul>
<li>当前类，相同包下不同的类</li>
<li>让子类对象使用</li>
</ul>
</blockquote>
<h2 id="9、内部类"><a href="#9、内部类" class="headerlink" title="9、内部类"></a>9、内部类</h2><h3 id="成员内部类"><a href="#成员内部类" class="headerlink" title="成员内部类"></a>成员内部类</h3><blockquote>
<p>1、在类的成员位置，和成员变量以及成员方法所在的位置是一样的</p>
<p>2、在内部类当中，可以直接访问外部类的成员，包括私有成员</p>
<p><strong>修饰符：</strong></p>
<ul>
<li>可以使用权限修饰符修饰成员内部类,但是如果使用私有来修饰，则无法在其他类中访问</li>
<li>可以使用static 修饰成员内部类，不用再创建外部类对象</li>
</ul>
<p><strong>匿名内部类：</strong></p>
<ul>
<li><p>必须在定义匿名内部类得时候创建它得对象</p>
</li>
<li><p>格式：</p>
<ul>
<li><p>new 类/接口(){</p>
</li>
<li><p>继承这个类得子类对象，可以重写父类方法</p>
</li>
<li><p>实现这个类得子类对象，必须实现这个接口得所有方法</p>
</li>
<li><p>}；</p>
</li>
</ul>
</li>
<li><p>原理：</p>
<ul>
<li>创建了继承这个类得子类对象或者创建了实现这个接口得子类对象</li>
</ul>
</li>
</ul>
<p><strong>应用场景：</strong></p>
<ul>
<li>作为参数传递 </li>
</ul>
</blockquote>
<pre><code class="java">package com.java;

/**
 * Created by JackFeng on 2020/3/15.
 */
public class InnerDemo &#123;
    public static void main(String[] args) &#123;

        Outer.Inner i = new Outer().new Inner();
        i.function();


    &#125;
&#125;


class Outer&#123;
    private int num = 10;

    public void  method()&#123;
        Inner i = new Inner();
        i.function();

    &#125;

    class Inner&#123;
        public void function()&#123;
            // 私有成员 可以i直接访问
            System.out.println(num);
        &#125;
    &#125;

&#125;
</code></pre>

  
  
    
    <div class='footer'>
      
      
        
  <div class="related_posts">
    <section class='header'>
      <i class="fas fa-bookmark fa-fw" aria-hidden="true"></i><span>相关文章</span>
    </section>
    <section class='body'>
      <div class="vlts-rps"><a class="item" href="\posts\2834.html" title="Java 常用API-II" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java 常用API-II</span><span class="excerpt">JavaAPP-II</span></a><a class="item" href="\posts\17415.html" title="Java环境" rel="bookmark "><img src="https://gitee.com/DataITems/cdn/raw/master/20200508000334.png" /><span class="title">Java环境</span><span class="excerpt">Java JDK 环境安装</span></a><a class="item" href="\posts\8589.html" title="Java面向对象(封装)" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java面向对象(封装)</span><span class="excerpt">Java面向对象 封装！</span></a><a class="item" href="\posts\32274.html" title="Java常用API" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java常用API</span><span class="excerpt">Java常用API-I</span></a><a class="item" href="\posts\9618.html" title="Java 集合体系" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java 集合体系</span><span class="excerpt">Java集合体系</span></a></div></section></div>
      
      
        <div class='copyright'>
          <blockquote>
            
              
                <p>版权声明：本网站所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="/">数据科学</a></p>

              
            
              
                <p>本文永久链接是：<a href=http://www.a2data.cn/posts/43249.html>http://www.a2data.cn/posts/43249.html</a></p>
              
            
          </blockquote>
        </div>
      
      
        <div class='donate'>
          <div class='imgs'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/alipay.jpg'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/wechat.png'>
            
          </div>
        </div>
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date" itemprop="dateUpdated" datetime="2020-09-18T10:25:45+08:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：Sep 18, 2020</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/tags/Java/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>Java</p></a></div>


        
      
        
      
        
          
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>4.2k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>17 min</p>
    </a>
  </div>


        
      
        
          
  <div class="new-meta-item share -mob-share-list">
  <div class="-mob-share-list share-body">
    
      
        <a class="-mob-share-qq" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.a2data.cn/posts/43249.html&title=Java面向对象 (继承、多态) - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java面向对象 继承 多态"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png">
          
        </a>
      
    
      
        <a class="-mob-share-qzone" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=http://www.a2data.cn/posts/43249.html&title=Java面向对象 (继承、多态) - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java面向对象 继承 多态"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png">
          
        </a>
      
    
      
        <a class="-mob-share-weibo" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.a2data.cn/posts/43249.html&title=Java面向对象 (继承、多态) - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java面向对象 继承 多态"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png">
          
        </a>
      
    
      
        
        <div class='hoverbox'>
          <a class='share'><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/wechat.png"></a>
          <div class='target'>
            <img src="">
          </div>
        </div>
      
    
  </div>
</div>



        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/posts/2834.html'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>Java 常用API-II</p>
          <p class='content'>JavaAPP-II



5、API-II5.0、常用类1、Object
String toString() : 返回对象得字符串表示
​    return getClass().getNa...</p>
        </a>
      
      
        <a class='next' href='/posts/32274.html'>
          <p class='title'>Java常用API<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>Java常用API-I



常用API1、String类功能赋值
String S = “hello “
Objcet： 是类层次结构的根类，所有类都直接活间接的继承该类

判断功能
bool...</p>
        </a>
      
    </div>
  
</article>


  

  <article class="post white-box reveal shadow" id="comments">
    <p ct><i class='fas fa-comments'></i> 评论</p>
    
    <div id="valine_container" class="valine_thread">
  <i class="fas fa-cog fa-spin fa-fw fa-2x"></i>
</div>

  </article>






</div>
<aside class='l_side'>
  
  
    
    

<section class="widget grid shadow desktop mobile">
  
  <header>
    
      <i class="fas fa-map-signs fa-fw" aria-hidden="true"></i><span class='name'>导航</span>
    
  </header>


  <div class='content'>
    <div class="grid navigation fixed">
      
        <a class="flat-box" title="/categories/" href="/categories/"
          
          
          id="categories">
          
            <i class="fas fa-book fa-fw fa-fw" aria-hidden="true"></i>
          
          内容大纲
        </a>
      
        <a class="flat-box" title="/archives/" href="/archives/"
          
          
          id="archives">
          
            <i class="fas fa-archive fa-fw fa-fw" aria-hidden="true"></i>
          
          文章归档
        </a>
      
        <a class="flat-box" title="/tags/" href="/tags/"
          
          
          id="tags">
          
            <i class="fas fa-fire fa-fw fa-fw" aria-hidden="true"></i>
          
          热门标签
        </a>
      
        <a class="flat-box" title="/Creator-said/" href="/Creator-said/"
          
          
          id="Creator-said">
          
            <i class="fas fa-comment-dots fa-fw fa-fw" aria-hidden="true"></i>
          
          主创说
        </a>
      
        <a class="flat-box" title="/contact/" href="/contact/"
          
          
          id="contact">
          
            <i class="fas fa-comments fa-fw fa-fw" aria-hidden="true"></i>
          
          留言板
        </a>
      
        <a class="flat-box" title="/friends/" href="/friends/"
          
          
          id="friends">
          
            <i class="fas fa-users fa-fw fa-fw" aria-hidden="true"></i>
          
          友情链接
        </a>
      
        <a class="flat-box" title="/" href="/"
          
          
            target="_blank"
          
          id="home">
          
            <i class="fas fa-clock fa-fw fa-fw" aria-hidden="true"></i>
          
          近期文章
        </a>
      
        <a class="flat-box" title="/tools/" href="/tools/"
          
          
          id="tools">
          
            <i class="fas fa-info-circle fa-fw fa-fw" aria-hidden="true"></i>
          
          软件控
        </a>
      
        <a class="flat-box" title="https://travellings.now.sh/" href="https://travellings.now.sh/"
          
            rel="noopener external nofollow noreferrer"
          
          
            target="_blank"
          
          id="https:travellingsnowsh">
          
            <i class="fa fa-binoculars fa-fw" aria-hidden="true"></i>
          
          开往
        </a>
      
    </div>
  </div>
</section>

  

  
    
    



  <section class="widget toc-wrapper shadow desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81static%E9%9D%99%E6%80%81"><span class="toc-text">1、static静态</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E4%BB%A3%E7%A0%81%E5%9D%97"><span class="toc-text">2、代码块</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E7%BB%A7%E6%89%BF"><span class="toc-text">3、继承</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#this%E5%92%8Csuper%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-text">this和super的区别</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81%E5%8C%BF%E5%90%8D%E5%AF%B9%E8%B1%A1-amp-final"><span class="toc-text">4、匿名对象&amp;final</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Final"><span class="toc-text">Final</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5%E3%80%81%E6%8A%BD%E8%B1%A1%E7%B1%BB"><span class="toc-text">5、抽象类</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6%E3%80%81%E6%8E%A5%E5%8F%A3"><span class="toc-text">6、接口</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7%E3%80%81%E5%A4%9A%E6%80%81"><span class="toc-text">7、多态</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%89%8D%E6%8F%90"><span class="toc-text">前提</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%89%B9%E7%82%B9"><span class="toc-text">特点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%A4%9A%E6%80%81%E8%BD%AC%E5%9E%8B"><span class="toc-text">多态转型</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8%E3%80%81%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6"><span class="toc-text">8、权限修饰符</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8C%85"><span class="toc-text">包</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8C%85%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF"><span class="toc-text">包使用场景</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9%E3%80%81%E5%86%85%E9%83%A8%E7%B1%BB"><span class="toc-text">9、内部类</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%90%E5%91%98%E5%86%85%E9%83%A8%E7%B1%BB"><span class="toc-text">成员内部类</span></a></li></ol></li></ol>
    </div>
  </section>


  


</aside>



      </div>
      
    
    <footer class="footer clearfix">
        <br><br>
        
            
                <br>
                <div class="social-wrapper">
                    
                        
                            <a href="https://github.com/A2Data"
                               class="social fab fa-github flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=a2data@163.com"
                               class="social fas fa-envelope-open flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="tencent://AddContact/?fromId=50&amp;fromSubId=1&amp;subcmd=all&amp;uin=66860619"
                               class="social fab fa-qq flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://gitee.com/DataITems/cdn/raw/master/baeab3a662ef96c3403f558a0bb578c.jpg"
                               class="social fab fa-weixin flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://me.csdn.net/weixin_47093227"
                               class="social fab fa-cuttlefish flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                </div>
                <div>
<!--                    <span id="timeDate"></span>-->
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <span id="times"></span>
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <script>
                        var now = new Date();
                        function createtime() {
                            var grt= new Date("12/18/2018 00:00:00");  //在此处修改你的建站时间，格式：月/日/年 时:分:秒
                            now.setTime(now.getTime()+250);
                            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
                            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
                            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
                            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
                            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
                            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
                            // document.getElementById("timeDate").innerHTML = "本站已运行 "+dnum+" 天 ";
                            document.getElementById("times").innerHTML = "本站已运行 "+dnum+" 天 "+ hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
                        }
                        setInterval("createtime()",250);
                    </script>
                </div>
                <div class="pure">
                    <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
                    <script>
                        var getOSAndBrowser = function () {
                            var os = navigator.platform;
                            var userAgent = navigator.userAgent;
                            var info = "";
                            var tempArray = "";
                            if (os.indexOf("Win") > -1) {
                                if (userAgent.indexOf("Windows NT 5.0") > -1) {
                                    info += "Win2000"
                                } else if (userAgent.indexOf("Windows NT 5.1") > -1) {
                                    info += "WinXP"
                                } else if (userAgent.indexOf("Windows NT 5.2") > -1) {
                                    info += "Win2003"
                                }
                                else if (userAgent.indexOf("Windows NT 6.0") > -1) {
                                    info += "WindowsVista"
                                } else if (userAgent.indexOf("Windows NT 6.1") > -1 || userAgent.indexOf("Windows 7") > -1) {
                                    info += "Win7"
                                } else if (userAgent.indexOf("Windows NT 6.2") > -1 || userAgent.indexOf("Windows 8") > -1) {
                                    info += "Win8"
                                }
                                else if (userAgent.indexOf("Windows NT 6.3") > -1 || userAgent.indexOf("Windows 8.1") > -1) {
                                    info += "Win8.1"
                                } else if (userAgent.indexOf("Windows NT 10.0") > -1 || userAgent.indexOf("Windows 10") > -1) {
                                    info += "Win10"
                                } else {
                                    info += "Other"
                                }
                            } else if (os.indexOf("Mac") > -1) {
                                info += "Mac"
                            } else if (os.indexOf("X11") > -1) {
                                info += "Unix"
                            } else if (os.indexOf("Linux") > -1) {
                                info += "Linux"
                            } else { info += "Other" } info += "/";
                            var isOpera = userAgent.indexOf("Opera") > -1;
                            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera;
                            var isEdge = userAgent.toLowerCase().indexOf("edge") > -1 && !isIE;
                            var isIE11 = (userAgent.toLowerCase().indexOf("trident") > -1 && userAgent.indexOf("rv") > -1);
                            if (/[Ff]irefox(\/\d+\.\d+)/.test(userAgent)) {
                                tempArray = /([Ff]irefox)\/(\d+\.\d+)/.exec(userAgent);
                                info += tempArray[1] + tempArray[2]
                            } else if (isIE) {
                                var version = "";
                                var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
                                reIE.test(userAgent);
                                var fIEVersion = parseFloat(RegExp["$1"]);
                                if (fIEVersion == 7) {
                                    version = "IE7"
                                } else if (fIEVersion == 8) {
                                    version = "IE8"
                                } else if (fIEVersion == 9) { version = "IE9" } else if (fIEVersion == 10) { version = "IE10" } else { version = "0" } info += version
                            } else if (isEdge) { info += "Edge" } else if (isIE11) { info += "IE11" } else if (/[Cc]hrome\/\d+/.test(userAgent)) { tempArray = /([Cc]hrome)\/(\d+)/.exec(userAgent); info += tempArray[1] + tempArray[2] } else if (/[Vv]ersion\/\d+\.\d+\.\d+(\.\d)* *[Ss]afari/.test(userAgent)) { tempArray = /[Vv]ersion\/(\d+\.\d+\.\d+)(\.\d)* *([Ss]afari)/.exec(userAgent); info += tempArray[3] + tempArray[1] } else if (/[Oo]pera.+[Vv]ersion\/\d+\.\d+/.test(userAgent)) { tempArray = /([Oo]pera).+[Vv]ersion\/(\d+)\.\d+/.exec(userAgent); info += tempArray[1] + tempArray[2] } else { info += "unknown" } return info
                        }; document.write("欢迎来自" + returnCitySN["cname"] + "的朋友"); document.write(",您的 IP 是:" + returnCitySN["cip"]); document.write(",您使用的是:" + getOSAndBrowser());
                    </script>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://hexo.io/" target="_blank" title="由 Hexo 强力驱动">
                        <span class="badge-subject">Powered</span><span class="badge-value bg-blue">Hexo</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://beian.miit.gov.cn" target="_blank" title="[sqlsq.cn@备案]">
                        <span class="badge-subject">京ICP</span><span class="github-badge .bg-lightgrey">备20010978号</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://github.com/" target="_blank" title="静态网页托管于 GitHub Pages 和 Gitee Pages">
                        <span class="badge-subject">Hosted</span><span class="badge-value bg-brightgreen">GitHub & Gitee</span></a>
                </div>
                <br>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.foreverblog.cn/blog/1579.html" target="_blank" title="[A2Data@十年之约]">
                        <span class="badge-subject">Forever Blog</span><span class="badge-value bg-lightgrey">十年之约</span></a>
                </div>

                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.a2data.cn/" target="_blank" title="DataScience提供内容创作">
                        <span class="badge-subject">Copyright © 2018-2020</span><span class="badge-value bg-blueviolet">A2Data</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.jsdelivr.com/" target="_blank" title="jsDelivr 提供 CDN 加速服务">
                        <span class="badge-subject">CDN</span><span class="badge-value bg-orange">jsDelivr</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="本站点采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可">
                        <span class="badge-subject"><i class="fa fa-copyright"></i></span><span class="badge-value bg-lightgrey">BY-NC-SA 4.0</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://996.icu/" target="_blank" title="支持 996.ICU">
                        <span class="badge-subject">Link</span><span class="badge-value bg-red">996.ICU</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://md.openwrite.cn/" target="_blank" title="OpenWrite.cn 特约提供服务">
                        <span class="badge-subject">微信</span><span class="badge-value bg-orange">公众号编辑器</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.leileitalk.com/" target="_blank" title="类类有话说 ">
                        <span class="badge-subject">类类</span><span class="badge-value bg-red">有话说</span></a>
                </div>

            
        
    </footer>


<style>
  .github-badge {
    display:inline-block;
    border-radius:4px;
    text-shadow:none;
    font-size:13px;
    color:#fff;
    line-height:15px;
    background-color:#ABBAC3;
    margin-bottom:5px;
  }
  .github-badge .badge-subject {
    display:inline-block;
    background-color:#4D4D4D;
    padding:4px 4px 4px 6px;
    border-top-left-radius:4px;
    border-bottom-left-radius:4px;
  }
  .github-badge .badge-value {
    display:inline-block;
    padding:4px 6px 4px 4px;
    border-top-right-radius:4px;
    border-bottom-right-radius:4px;
  }
  .github-badge .bg-brightgreen {
    background-color:#4DC820 !important;
  }
  .github-badge .bg-orange {
    background-color:#FFA500 !important;
  }
  .github-badge .bg-yellow {
    background-color:#D8B024 !important;
  }
  .github-badge .bg-blueviolet {
    background-color:#8833D7 !important;
  }
  .github-badge .bg-pink {
    background-color:#F26BAE !important;
  }
  .github-badge .bg-red {
    background-color:#e05d44 !important;
  }
  .github-badge .bg-blue {
    background-color:#007EC6 !important;
  }
  .github-badge .bg-lightgrey {
    background-color:#9F9F9F !important;
  }
  .github-badge .bg-grey, .github-badge .bg-gray {
    background-color:#555 !important;
  }
  .github-badge .bg-lightgrey, .github-badge .bg-lightgray {
    background-color:#9f9f9f !important;
  }
</style>

      <a class="s-top fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md").find("img").not('.inline').not('a img').each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      // 背景层
      var bgDiv = document.createElement("div");
      $(bgDiv).addClass("bg");
      if ($(this).attr('bg')) {
        $(bgDiv).css('background', $(this).attr('bg'));
      }
      $(this).wrap(bgDiv); // 背景层
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if($(".md").find("img").not('.inline').not('a img').length+$(".article-entry").find("img").length==0)return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->



  
  
  <div id="rightmenu-wrapper">
    <ul class="list-v rightmenu" id="rightmenu-content">

      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' 
      
      
      
         onclick="menuCopy()"
              
      
         id="menu-copy-text"
      >
        <i class='fas fa-copy fa-fw'></i> 复制选中内容
      </a>
    </li>
  
        
      
        
          <li class='navigation'>
            <a class='nav icon-only fix-cursor-default' onclick='history.back()'><i class='fas fa-arrow-left fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='history.forward()'><i class='fas fa-arrow-right fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='window.location.reload()'><i class='fas fa-redo fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' href='/'><i class='fas fa-home fa-fw'></i></a>
          </li>
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://support.qq.com/products/176810/
      
      
      
      
         id="https:supportqqcomproducts176810"
              >
        <i class='fa fa-question fa-fw'></i> 吐槽墙
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/tools/
      
      
      
      
         id="tools"
              >
        <i class='fa-fw fa fa-bars fa-fw fa-fw'></i> 软件控
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://gitee.com/DataITems/cdn/raw/master/sys.png
      
      
      
      
         id="https:giteecomDataITemscdnrawmastersyspng"
              >
        <i class='fa fa-fan fa-spin fa-fw'></i> 公众号
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/about/
      
      
      
      
         id="about"
              >
        <i class='fas fa-location-arrow fa-fw'></i> 如人饮水
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/Creator-said/
      
      
      
      
         id="Creator-said"
              >
        <i class='fa fa-globe fa-fw fa-fw'></i> 冷暖自知
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          <li class='music name'>
            <p class='nav music-title fix-cursor-default'></p>
          </li>
          <li class='music ctrl'>
            <a class='nav icon-only backward' onclick='aplayerBackward()'><i class='fas fa-step-backward fa-fw'></i></a>
            <a class='nav icon-only toggle' onclick='aplayerToggle()'><i class='fas fa-play fa-fw'></i></a>
            <a class='nav icon-only forward' onclick='aplayerForward()'><i class='fas fa-step-forward fa-fw'></i></a>
          </li>
          <li class='music volume'>
            <a class='nav volume'>
              <div class="aplayer-volume-bar-wrap">
                <div class="aplayer-volume-bar fix-cursor-pointer">
                  <div class="aplayer-volume"></div>
                  <i class='left fas fa-volume-off fa-fw'></i>
                  <i class='right fas fa-volume-up fa-fw'></i>
                </div>
              </div>
            </a>
          </li>
        
      
    </ul>
  </div>
  <script>
    window.document.oncontextmenu = function (event) {
      if (event.ctrlKey || $(window).width() <= 500) {
        if (event.ctrlKey) return true;
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) return true;
      }
      setMenulocation();
      setMenuCopy();
      if (true == true) {
        try {
          checkAPlayer();
          updateTitle();
        } catch (error) {console.log(error);}
      }
      return false;
    };
    document.getElementById('rightmenu-wrapper').oncontextmenu  = function (event) {
      event.stopPropagation();  // 阻止右键上的右键
      return false;
    }
    document.querySelectorAll('img').forEach((item) => {  // IMG 放出菜单
      item.oncontextmenu  = function (event) {
        event.stopPropagation();
        return true;
      }
    })
    document.addEventListener("click", function (event) {
      hideMenu();
    });
    function hideMenu(  ) {
      document.getElementById('rightmenu-wrapper').style.display = 'none';
    }
    function setMenulocation() {
      var mymenu = document.getElementById('rightmenu-wrapper');
      var menuContent = document.getElementById('rightmenu-content');
      var mouseClientX = event.clientX;
      var mouseClientY = event.clientY;
      var menuWidth = menuContent.offsetWidth == 0 ? 160 : menuContent.offsetWidth;
      var menuHeight = menuContent.offsetHeight == 0 ? 340 : menuContent.offsetHeight;
      var screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
      var screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
      var showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
      var showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
      mymenu.style.left = showLeft + "px";
      mymenu.style.top = showTop + "px";
      mymenu.style.display = 'block';
    }
    function setMenuCopy() {
      if (window.getSelection().toString()) {
        document.getElementById('menu-copy-text').style.display = 'block';
      } else {
        document.getElementById('menu-copy-text').style.display = 'none';
      }
    }
    function menuCopy() {
      document.execCommand("Copy");
      $.message({title:'复制成功',message: window.getSelection().toString(),type:'success'});
    }
  </script>





  
<script src="/js/issues.js" aysc></script>




  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  




  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn-copy', {
        target: function (trigger) {
            return trigger.nextElementSibling
        }
    });
    function wait(callback, seconds) {
        var timelag = null;
        timelag = window.setTimeout(callback, seconds)
    }
    function pjax_initCopyCode() {
		if($(".highlight .code pre").length+$(".article pre code").length==0)return;
        var copyHtml = '';
        copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
        copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
        copyHtml += '</button>';
        $(".highlight .code pre").before(copyHtml);
        $(".article pre code").before(copyHtml);
        clipboard.off('success').on('success', function (e) {
            $.message({
            title: '复制成功',
            message: "代码已复制，请遵守相关授权协议。",
            type: 'success'
        });
            let $btn = $(e.trigger);
            $btn.addClass('copied');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-check-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPIED';
            wait(function () {
                $icon.removeClass('fa-check-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        });
        clipboard.off('error').on('error', function (e) {
            e.clearSelection();
            let $btn = $(e.trigger);
            $btn.addClass('copy-failed');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-times-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPY FAILED';
            wait(function () {
                $icon.removeClass('fa-times-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        })
    }
    $(function () {
        pjax_initCopyCode()
    });
</script>




   <script src="https://cdn.jsdelivr.net/npm/scrollreveal@4.0.6/dist/scrollreveal.min.js"></script>
<script type="text/javascript">
  function pjax_scrollrebeal() {
    ScrollReveal().reveal('.l_main .reveal', {
      distance: '32px',
      duration: '800',
      interval: '20',
      scale: '1',
      easing: 'ease-out'
    });
  }
  $(function () {
    pjax_scrollrebeal();
  });
</script>




  <script>
  let APlayerController = new Object();
  APlayerController.id = '5229739363';  // 设定全局音乐播放ID
  APlayerController.volume = '0.3';
  APlayerController.autoPlay = 'true';
</script>

  
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.js"></script>


  
<script src="https://cdn.jsdelivr.net/npm/meting@2.0/dist/Meting.min.js"></script>




  
<script src="/js/aplayer.js"></script>






  <!--https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js-->
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js"></script>

  
<script src="https://cdn.jsdelivr.net/npm/valine@1.4/dist/Valine.min.js"></script>


<script>
  var GUEST_INFO = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link'.split(',').filter(function (item) {
    return GUEST_INFO.indexOf(item) > -1
  });
  var REQUIRED_FIELDS = ['nick', 'mail', 'link'];
  var requiredFields = 'nick,mail'.split(',').filter(function (item) {
    return REQUIRED_FIELDS.indexOf(item) > -1
  });

  function emoji(path, idx, ext) {
    return path + "/" + path + "-" + idx + "." + ext;
  }

  var emojiMaps = {};
  for (var i = 1; i <= 54; i++) {
    emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
  }
  for (var i = 1; i <= 101; i++) {
    emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
  }
  for (var i = 1; i <= 116; i++) {
    emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
  }
  for (var i = 1; i <= 125; i++) {
    emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
  }
  for (var i = 1; i <= 4; i++) {
    emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
  }

  function pjax_valine() {
    if(!document.querySelectorAll("#valine_container")[0])return;

    let pagePlaceholder = $.trim($('#pjax-comment-placeholder').text()) || "嗨,请不要吝啬你的想法！小技巧：在昵称位置输入QQ号就可以自动补全邮箱哦~";

    let path = $.trim($('#pjax-comment-path').text());
    if (path.length == 0) {
      let defaultPath = '';
      path = defaultPath || decodeURI(window.location.pathname);
    }

    var valine = new Valine();
    valine.init({
      el: '#valine_container',
      meta: meta,
      placeholder: pagePlaceholder,
      path: path,
      appId: "i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz",
      appKey: "GXgwCzMM0g2CnM8x0WCM7fPQ",
      pageSize: '5',
      avatar: 'robohash',
      lang: 'zh-cn',
      visitor: 'true',
      highlight: 'true',
      mathJax: 'false',
      enableQQ: 'true',
      requiredFields: requiredFields,
      emojiCDN: 'https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/',
      emojiMaps: emojiMaps
    })
  }

  function newcomment() {

    function queryLeanCloud(k) {
      let root = this;
      let len = arguments.length;
      if (len == 1) {
        let notExist = new AV.Query("Comment");
        notExist.doesNotExist('rid');
        let isEmpty = new AV.Query("Comment");
        isEmpty.equalTo('rid', '');
        let q = AV.Query.or(notExist, isEmpty);
        if (k === '*') q.exists('url');
        else q.equalTo('url', decodeURI(k));
        q.addDescending('createdAt');
        q.addDescending('insertedAt');
        return q;
      } else {
        let ids = JSON.stringify(arguments[1]).replace(/(\[|\])/g, '');
        let cql = `select * from ${root['config']['clazzName']} where rid in (${ids}) order by -createdAt,-createdAt`;
        return AV.Query.doCloudQuery(cql)
      }
    }
    var valine = new Valine({
      el: '#valine_container_ba（因为主题已经有valine的这些参数了，这里随意填都行）',
      app_id: 'i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz',
      app_key: 'GXgwCzMM0g2CnM8x0WCM7fPQ',
      placeholder: '',
      serverURLs: 'https://i1i90mfu.lc-cn-n1-shared.com'
    });

    //判断博主，heson改为自己的昵称
    function bozhu(e){
      if (e == "Jack"){
        nick = e + '[博主]'
        return nick;
      } else {
        return e
      }
    }

    //判断网址
    function wangzhi(e){
      http = e.slice(0,4)
      https = e.slice(0,5)
      if (http == "http" || https == "https" ){
        return e
      } else if (e == "" || e == null || e == undefined){
        return e
      } else {
        e = 'http://'+ e
        return e
      }
    }

    //查询评论
    valine.Q('*').limit(7).find().then(function (comments) {
      var hotComments = $("#hot-comments");
      for (var i = 0; i < comments.length; i++) {
        if (i === 0) {
          // console.log(comments[0]);
          console.log("\n %c DataScience %c https://www.a2data.cn \n", "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;"),
          window.customElements && !window.customElements.get("meting-js") && (window.MetingJSElement = MetingJSElement,
                  window.customElements.define("meting-js", MetingJSElement));

        }
        var nick = bozhu(comments[i]._serverData.nick);
        var content = comments[i]._serverData.comment;
        // var newcontent = content.substring(0, 50).replace(/<[^>]+>/g,"");
        var newcontent = content.replace(/<[^>]+>/g,"").replace(/:.*?:/g,"[表情]").substring(0,50);
        var url = comments[i]._serverData.url;
        var link = wangzhi(comments[i]._serverData.link);
        var updatedAt = timeago(comments[i].updatedAt);
        var commentId = '#' + comments[i].id;
        hotComments.append('<div class="card-comment-item"><div class="item-header-text"><a href="'+ link +'" target="_blank" rel="nofollow noopener noreferrer" class="newcomment" >' + nick + '</a>&nbsp;发表于' + updatedAt + '</div><div class="item-text"><a href="' + url + commentId +'"  rel="nofollow" style="color:#717171" class="comments-detail" >' + newcontent + '</a></div></div>');
      }
    });
  };

  $(function () {
    pjax_valine();
    newcomment();
  });
</script>







  <script defer src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-busuanzi@2.3/js/busuanzi.pure.mini.js" data-pjax></script>


  
<script src="/js/app.js"></script>




  
    
<script src="/js/search.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/" || "/").endsWith('/') ? ("/" || "/") : ("//" || "/" );
(function ($) {
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
})(jQuery);

</script>







  
<script src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@2/js/comment_typing.js"></script>




  
    
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.1/build/highlight.min.js"></script>

    <script>hljs.initHighlightingOnLoad();</script>
  



  <script defer>

  const LCCounter = {
    app_id: 'Fsrd5NtVW8ovmaynVJ18xHO6-gzGzoHsz',
    app_key: 'QYc2X76ulK8THVLHwpJfvsrG',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'http://www.a2data.cn' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>



<!-- more -->


    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>

<!-- 样式位于：source/css/_third-party/pjaxanimate.styl -->

<div class="pjax-animate">
  
    <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>
    <div id="loading-bar-wrapper"><script>NProgress.configure({parent:"#loading-bar-wrapper",trickleSpeed: 100})</script></div>
    <script>
      window.ShowLoading = function() {
        NProgress.start();
      };
      window.HideLoading = function() {
        NProgress.done();
      }
    </script>
  
</div>

<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = ["/Creator-said/"];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      $('.l_header .switcher .s-search').removeClass('active'); // 关闭移动端激活的搜索框
      $('.l_header').removeClass('z_search-open'); // 关闭移动端激活的搜索框
      $('.wrapper').removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      $('.s-top').unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
      window.ShowLoading();
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
            newcomment();
          }
        
        
        document.querySelectorAll('pre code').forEach((block) => {
          hljs.highlightBlock(block);
        });
        
        
          pjax_scrollrebeal();
        
        
          pjax_initCopyCode();
        
        
          pjax_valine();
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
      window.HideLoading();
    });

    document.addEventListener('pjax:error', function (e) {
      window.HideLoading();
      window.location.href = e.triggerElement.href;
    });
</script>

    

      <!--聊天-->

      <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="9e16adc4-63cc-4958-bf99-26d19bf0ede8";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>

      <!--    title 变化-->
      <script type="text/javascript">
        var OriginTitile=document.title,st;
        document.addEventListener("visibilitychange",function(){
          document.hidden?(document.title="ヽ(●-`Д´-)ノ嗨说你呢，别分心",clearTimeout(st)):(document.title="(Ő∀Ő3)ノ欢迎回来！",st=setTimeout(function(){document.title=OriginTitile},3e3))
        })
      </script>

  </div>
</body>
</html>
